export default function detailCanvas(that,share_pic,sWidth,sHeight,headimgUrl,codeImg,title,callback){
    const width = wx.getSystemInfoSync().windowWidth-35// 获取设备宽度
    const height = wx.getSystemInfoSync().screenHeight // 获取设备高度

    let rpx = sWidth;
    const cxt = wx.createCanvasContext('myCanvas',that);
    cxt.save();
    cxt.setFillStyle('#fff')
    cxt.fillRect(0, 0, sWidth*375, sHeight-100);
    
    var avatorWidth = sWidth *50,avatorHeight = sWidth * 50;
    var avatarurlX =sWidth*375/2-50; 
    var avatarurlY =35;
    cxt.save();
    cxt.beginPath();
    
    cxt.drawImage(share_pic,0,0,wx.getSystemInfoSync().windowWidth-35, wx.getSystemInfoSync().windowHeight-100);
    cxt.restore();
    cxt.arc(avatorWidth / 2 + avatarurlX, avatorHeight / 2 + avatarurlY, avatorWidth / 2, 0, Math.PI * 2, false);
    cxt.clip();
    cxt.drawImage(headimgUrl,sWidth*375/2-50,35, avatorWidth, avatorWidth);
    cxt.restore();
    cxt.drawImage(codeImg,(sWidth*375-sWidth*375/2+25)/2, wx.getSystemInfoSync().windowHeight/2-70,sWidth*375/2-50,sWidth*375/2-50);
    cxt.restore();

    var e=(width-cxt.measureText(title).width-30)/2;//距离左边距离
    var i=95;//距离顶部距离
    var o=cxt.measureText(title).width+30;//背景色宽度
    var n=22;
    var s=11;
    var a='#FFEFE1';
    var c='#FFEFE1';
    cxt.beginPath();
    cxt.arc(e + s, i + s, s, Math.PI, 1.5 * Math.PI),
    cxt.moveTo(e + s, i), 
    cxt.lineTo(e + o - s, i),
    cxt.arc(e + o - s, i + s, s, 1.5 * Math.PI, 2 * Math.PI), 
    cxt.lineTo(e + o, i + n - s), 
    cxt.arc(e + o - s, i + n - s, s, 0, .5 * Math.PI), 
    cxt.lineTo(e + s, i + n), 
    cxt.arc(e + s, i + n - s, s, .5 * Math.PI, Math.PI),
    cxt.lineTo(e, i + s), a && (cxt.setFillStyle(a), 
    cxt.fill()), c && (cxt.setStrokeStyle(c), cxt.stroke()),cxt.clip();
    cxt.closePath();

    cxt.setFontSize(12);
    cxt.setFillStyle('rgb(218,60,11)');
    cxt.fillText(title,(width - cxt.measureText(title).width) * 0.5 ,111); 
    
  
  
  cxt.draw(false,()=>{
      wx.canvasToTempFilePath({
          x: 0,
          y: 0,
          canvasId:"myCanvas",
          fileType: 'png',
          success: (res)=>{
              callback(res.tempFilePath)
          },
         
      }, that);
  });
}